$(document).ready
(
	function()
	{
		$('#sandboxApi').submit
		(
			function(e)
			{
				var params = new Object();

				$('input[type=text]').each
				(
					function()
					{
						var name = $(this).attr('name');
						var value = $(this).val();

						if
						(
							value != null &&
							value != ''
						)
						{
							params[name] = value;
						}
					}
				);

				var extensionId = $('#extensionId').val();
				var apiName = $('#apiName').val();
				var className = $('#className').val();


				Common.Api.callJson
				(
					extensionId,
					className,
					apiName,
					params,
					function(result)
					{
						$('#resultApi').html('Success');
					},
					function(result)
					{
						var errorContext = result.errorContext;

						var error = '';

						for(attributs in errorContext)
						{
							error += attributs + ' : ' + errorContext[attributs] + '<br />';
						}

						$('#resultApi').html('Fail<br/>' + result.errorCode + '<br />Context : ' + error);
						console.log(result);
					},
					true					
				);
				
				
				return false;
			}
		);
	}
);